/*
 * libmanyuc - read buttons with debounce example
 * Copyright (C) 2013 - Margarita Manterola Rivero
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301 USA
 */

#include "libmanyuc.h"

/* This example counts using the leds, when button in P19 is pressed.
 * The button is in PullUp mode, returns 0 when pressed. */

int main() {

    Pin button = Pin(P19, 2, Input, PullUp);

    Bus leds(4, LED1, LED2, LED3, LED4);
    leds.mode(Output);

    int counter = 0;
    while (1) {
        if (button.read_debounce() == SW_ON) {
            leds = counter++;
        }
    }
}
// vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
